class Box: def setdata(self,x,y,z): self.L=x self.B=y self.H=z def volume(self): v=self.L*self.B*self.H print("Volume is ",v) def surfacearea(self): a=2*self.L*self.H+2*self.B*self.H+2*self.L*self.B print("SurfaceArea is ",a) class OpenBox(Box): def surfacearea(self): a=2*self.L*self.H+2*self.B*self.H+self.L*self.B print("SurfaceArea is ",a) a=Box() a.setdata(2,2,2) a.volume() a.surfacearea() b=OpenBox() b.setdata(1,1,1) b.volume() b.surfacearea()
Volume is 8 Surface Area is 24 Volume is 1 Surface Area is 5
class Account: def open(self,an,bl): self.accno=an self.balance=bl def deposit(self,amt): self.balance=self.balance+amt def withdraw(self,amt): self.balance=self.balance-amt def showBalance(self): print("AccNo is ",self.accno) print("Balance is",self.balance) class CAccount(Account): def deposit(self,amt): self.balance=self.balance+amt self.balance=self.balance -1 def withdraw(self,amt): self.balance=self.balance-amt self.balance=self.balance -1 a=Account() a.open(4117,25000) a.deposit(3000) a.withdraw(8000) a.showBalance() b=CAccount() b.open(3012,10000) b.deposit(5000) b.withdraw(2000) b.withdraw(3000) b.showBalance()
AccNo is 4117 Balance is 20000 AccNo is 3012 Balance is 9997
class Account: def open(self,an,bl): self.accno=an self.balance=bl def deposit(self,amt): self.balance=self.balance+amt def withdraw(self,amt): self.balance=self.balance-amt def showBalance(self): print("AccNo is ",self.accno) print("Balance is",self.balance) class CAccount(Account): def deposit(self,amt): Account.deposit(self,amt) self.balance=self.balance-1 def withdraw(self,amt): Account.withdraw(self,amt) self.balance=self.balance-1 a=Account() a.open(4117,25000) a.deposit(3000) a.withdraw(8000) a.showBalance() b=CAccount() b.open(3012,10000) b.deposit(5000) b.withdraw(2000) b.withdraw(3000) b.showBalance()
AccNo is 4117 Balance is 20000 AccNo is 3012 Balance is 9997
class Person: def setdata(self,name,city): self.name=name self.city=city def showdata(self): print("Name is ",self.name) print("City is ",self.city) class Student(Person): def setdata(self,rollno,name,city): self.rollno=rollno Person.setdata(self,name,city) def showdata(self): print("RollNo is",self.rollno) Person.showdata(self) a=Person() a.setdata("Amit jain","Amravati") a.showdata() b=Student() b.setdata(4117,"Gopal Pandey" ,"Nagpur") b.showdata( )
Name is Amit Jain City is Amravati RollNo is 4117 Name is Gopal Pandey City is Nagpur